﻿using DataChangeTools.Models;
using HandyControl.Tools.Extension;
using Prism.Dialogs;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace DataChangeTools.Views
{
    /// <summary>
    /// BatchRenameWithImage.xaml 的交互逻辑
    /// </summary>
    public partial class BatchRenameWithImage : System.Windows.Controls.UserControl
    {
        private readonly IDialogService _dialogService;

        public BatchRenameWithImage(IDialogService dialogService)
        {
            InitializeComponent();
            _dialogService = dialogService;
        }

        private void Image_MouseDown(object sender, MouseButtonEventArgs e)
        {

            // 获取触发事件的 Image 控件
            System.Windows.Controls.Image image = sender as System.Windows.Controls.Image;


            var sss = image.DataContext as string;
            var sss1 = image.Name as string;
            BitmapImage bmi = new BitmapImage();
            bmi.BeginInit();
            //bmi.UriSource = new Uri(, UriKind.Absolute);
            if (image.Source is BitmapFrame bitmapImage)
            {
                var decoder = bitmapImage.Decoder;

                // 将 URI 转换为字符串形式的地址
                string imagePath = decoder.ToString();

                DialogParameters dialogParameters = new DialogParameters();
                dialogParameters.Add("CodeImg", imagePath);
                // ImageViewDialog imageViewDialog = new ImageViewDialog();
                //imageViewDialog.Show();
                _dialogService.Show("ImageViewDialog", dialogParameters, result =>
                {
                    // 弹窗关闭后的回调
                    if (result.Result == ButtonResult.OK)
                    {
                        // 处理OK按钮的逻辑

                    }
                    else if (result.Result == ButtonResult.Cancel)
                    {
                        // 处理Cancel按钮的逻辑
                    }
                });
            }


        }
    }
}
